﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Management;
using System.Text;
using WMI.NET.Abstracts;
using WMI.NET.CIM;

namespace WMI.NET.ComputerSystemHardware.MotherboardControllerPort
{
    /// <summary>
    /// The Win32_OnBoardDevice WMI class represents common adapter devices built into the motherboard (system board).
    /// </summary>
    public class Win32_OnBoardDevice : CIM_PhysicalComponent
    {

        private Nullable<UInt16> _DeviceType;
        private Nullable<Boolean> _Enabled;

        /// <summary>
        /// Type of device being represented.
        /// </summary>
        public Nullable<UInt16> DeviceType { get { return _DeviceType; } } //TODO enum

        /// <summary>
        /// If TRUE, the on-board device is available for use. 
        /// </summary>
        public Nullable<Boolean> Enabled { get { return _Enabled; } }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="mbo"></param>
        public Win32_OnBoardDevice(ManagementBaseObject mbo)
            :base(mbo)
        {
            _DeviceType = mbo.GetUshortValue("DeviceType");
            _Enabled = mbo.GetBoolValue("Enabled");
        }

    }

    /// <summary>
    /// 
    /// </summary>
    public class GetWin32_OnBoardDevices : Win32Collection<Win32_OnBoardDevice>
    {

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override ReadOnlyCollection<Win32_OnBoardDevice> GetCollection()
        {
            List<Win32_OnBoardDevice> tempCollection = new List<Win32_OnBoardDevice>();

            foreach (var s in searcher.Get())
            {
                Win32_OnBoardDevice tempListItem = new Win32_OnBoardDevice(s);
                tempCollection.Add(tempListItem);
            }

            return tempCollection.AsReadOnly();
        }

        /// <summary>
        /// 
        /// </summary>
        public GetWin32_OnBoardDevices() : base("SELECT * FROM Win32_OnBoardDevice") { }

    }


}
